<template>
	<view>
		<view class="cu-list menu-avatar " >
			<view class="cu-item " v-for="(item,index) in listData" :key="index" v-if="dtype == 1">
			
				<view class="cu-avatar radius lg" style="background-image: url(http://image4.ailemon.cc/douyin-logo.jpg)"
				 v-if="dtype == 2"></view>
				<view class="cu-avatar radius lg" :style="'background-image: url('+item.thumbnail+')'"
				 v-if="dtype == 1 && item.thumbnail != null"></view>
				 <view class="cu-avatar radius lg" style="background-image: url(http://image4.ailemon.cc/kuaishou-logo.jpeg)"
				  v-if="dtype == 1 && item.thumbnail == null"></view>
				
				  
				<view class="content">
					<view class="">
						<view class="text-cut">{{item.stime}}</view>
					</view>
					<view class="text-gray text-sm flex">
						<view class="cu-tag round bg-blue light" v-if="item.classType == 1">手机壁纸</view>
						<view class="cu-tag round bg-blue light" v-if="item.classType == 2">动态壁纸</view>
						<view class="cu-tag round bg-blue light" v-if="item.classType == 3">背景图</view>
						<view class="cu-tag round bg-blue light" v-if="item.classType == 4">头像</view>
						<view class="cu-tag round bg-blue light" v-if="item.classType == 5">表情包</view>
						
						<view class="cu-tag round bg-blue light">{{dtype == 1 ? '广告' : '邀请'}}</view>
						<view class="cu-tag round bg-blue light" v-if="item.status == 1">待结算</view>
						<view class="cu-tag round bg-blue light" v-if="item.status == 2">待入账</view>
						<view class="cu-tag round bg-blue light" v-if="item.status == 3">已入账</view>
					</view>
				</view>
				<view class="action">
					<view class="text-red text-lx">{{item.downCount}}个</view>
					<view class="cu-tag round bg-red sm" v-if="item.status == 2 || item.status == 3">￥{{ item.money }}</view>
				</view>
			</view>
			
			<view class="cu-item " v-for="(item,index) in listData" :key="index" v-if="dtype == 2">
				<view class="cu-avatar radius lg" v-if="item.platformType == 5"
				style="background-image: url(http://image4.ailemon.cc/kuaishou-logo.jpeg)">
				</view>
				<view class="cu-avatar radius lg" v-if="item.platformType == 4"
				style="background-image: url(http://image4.ailemon.cc/douyin-logo.jpg)">
				</view>
					<view class="content">
						<view class="">
							<view class="text-cut">{{ item.flowNo }}</view>
						</view>
						<view class="text-gray text-sm flex">
							<view class="text-cut">{{ item.createTime }}</view>
						</view>
					</view>
					<view class="action">
						<view class="text-grey text-xs">{{ title2 }}</view>
						<view class="cu-tag round bg-red sm" v-if="item.status == 2 || item.status == 3">￥{{ item.money }}</view>
					</view>
				</view>
			</view>

			<!--加载loadding-->
			<tui-loadmore :visible="loadding"></tui-loadmore>
			<tui-nomore :visible="!pullUpOnLast" bgcolor="#ffffff"></tui-nomore>
			<!--加载loadding-->
		</view>
	</view>
</template>

<script>
import tuiLoading from '../../components/loading/loading';
import tuiLoadmore from '../../components/loadmore/loadmore';
import tuiNomore from '../../components/nomore/nomore';

const http = require('../../utils/http.js');

const Constants = require('../../utils/constants');

export default {
    components: {
        tuiLoading,
        tuiLoadmore,
        tuiNomore
    },
    data() {
        return {
			dtype:1,
            title: '',
			title2:'',
            loadding: false,
            listData: [],
            pullUpOnLast: true,
        };
    },
    onLoad: function (options) {
        let title = '广告收益明细';
		
		let title2 = '待结算';
		
		if(options.dtype == 2){
			if (options.status == 1) {
				this.title2 = '待结算';
			} else {
			    if (options.status == 2) {
			        this.title2 = '待入账';
			    } else {
			        if (options.status == 3) {
			            this.title2 = '已入账';
			        }
			    }
			}
			
			title = "邀请收益明细"
		}

        uni.setNavigationBarTitle({
            title: title
        });
        this.setData({
            status: options.status,
			dtype: options.dtype,
			createTime:options.time,
			platformType:options.platformType
        });
		
		if(this.dtype == 1){
			this.list(false);
		}else if(this.dtype == 2){
			this.listYq(false);
		}
        
    },
    onPullDownRefresh: function () {},
    onReachBottom: function () {
        if (!this.pullUpOnLast) {
            return;
        }
		if(this.dtype == 1){
			this.list(false);
		}else if(this.dtype == 2){
			this.listYq(false);
		}

    },
    methods: {
        jumpClick: function (e) {
            let link = e.currentTarget.dataset.link;
            uni.navigateTo({
                url: link,
                // 指定页面的 url
                success: (res) => {},
                fail: (res) => {}
            });
        },

        list: function (refresh) {
            let that = this;
            that.setData({
                loadding: true
            });
            let offset = 0;

            if (!refresh) {
                offset = that.listData.length;
            }
			uni.showLoading({
				title:'加载中'
			})
            var params = {
                url: '/p/balance/listNew',
                method: 'GET',
                data: {
                    offset: offset,
                    status: that.status,
                    dataType: 1,
					stime:that.createTime,
					platformType:that.platformType
                },
                callBack: function (res) {
                    that.setData({
                        loadding: false,
                        listData: refresh ? res.data.list : that.listData.concat(res.data.list),
                        pullUpOnLast: !res.data.isLastPage ? true : false
                    });
					uni.hideLoading()
                }
            };
            http.request(params);
        },
		
		// 邀请收益数据
		listYq: function (refresh) {
		    let that = this;
		    that.setData({
		        loadding: true
		    });
		    let offset = 0;
		
		    if (!refresh) {
		        offset = that.listData.length;
		    }
			uni.showLoading({
				title:'加载中'
			})
		    var params = {
		        url: '/u/distributionProfit/list',
		        method: 'GET',
		        data: {
		            offset: offset,
		            status: that.status,
					stime:that.createTime,
					platformType:that.platformType
		        },
		        callBack: function (res) {
		            that.setData({
		                loadding: false,
		                listData: refresh ? res.data.list : that.listData.concat(res.data.list),
		                pullUpOnLast: !res.data.isLastPage ? true : false
		            });
					uni.hideLoading()
		        }
		    };
		    http.request(params);
		},
		
    }
};
</script>
<style>
@import './adprofit.css';
</style>
